<!--{Atemplate tpl/header}-->

<script charset="utf-8" src="{Acan_path_plugin}/My97DatePicker/WdatePicker.js"></script>
<!--{eval echo $this->Ahtml_js_aurl();}-->
<!--{Atemplate customer/area}-->
<script>
var columns = {"$this->model->table":$column_json,"$this->msms->table":$coljson[sms]};
Acontextmenu = function(){
	return {
		"跟进客户":{"onclick":"CRM.track.open('$this->Aapp-track-customer-\\id')"},
		<!--{if $this->Aact=='list'}-->
		"变更此客户":{"onclick":"CRM.change.view(\id)"},
		"变更已择客户":{"onclick":"CRM.change.check()"},
		<!--{elseif $this->Aact=='my'}-->
		"放弃客户":{"onclick":"if(confirm('确实要放弃此客户吗?')) CRM.customer.forgo('\\id');"},
		"短信订阅":{"onclick":"Aformsms.add(\\sid,'短信订阅','',{cid:\\id})"},
		<!--{/if}-->
		"编辑客户":{"onclick":"Aform.add(\\id,'客户编辑','_add')"}
		//"删除客户":{"onclick":"if(confirm('确实要删除吗?')) Aform.del('\id');"}
	};
};
var model = $listjson;
function checkall(value) {
	if(value=='0'){
		jQuery(".checkbox").attr("checked","checked");
		jQuery("#chkall_del").removeAttr("disabled","disabled");
	}
	if(value=='1'){
		jQuery(".checkbox").removeAttr("checked","checked");
		jQuery("#chkall_del").attr("disabled","disabled");
	}
	if(value=='auth'){
		var chkall = jQuery("input:checked").val();
		if(chkall == null){
			alert('请先选择');
			return false;
		}else{
			return true;
		}
	}
}
var Aform = new Apps.form('customer','Aform',{'add':{width:640,height:'auto'}},columns.$this->model->table,{info:'$this->Amodr-info-',save:'$this->Amodr-save-one'});
var Aformsms = new Apps.form('sms','Aformsms',{'add':{width:480,height:'auto'}},columns.$this->msms->table,{info:'$this->Aapp-sms-info-',save:'$this->Aapp-sms-save-one'});
//页面载入后执行
jQuery(document).ready(function(){
	
	//初始右击菜单
	jQuery(".-body").append(Ahtml.tag('div',{"class":"_contextmenu"}));
	//菜单右击
	jQuery(".-main_list ._tr").bind("contextmenu", function(e){
		jQuery(".-main_list ._tr").removeClass('_contextmenu_hover');
		jQuery(this).addClass('_contextmenu_hover');
		var id = jQuery(this).attr('id');
		var html = '';
		var cmenus = Acontextmenu();
		for(var i in cmenus){
			for(var n in cmenus[i]){
				cmenus[i][n] = cmenus[i][n].replace(/\\id/g,id).replace(/\\sid/g,model[id].sid);
			}
			html += Ahtml.tag("p",cmenus[i],i);
		}
		jQuery(".-body ._contextmenu").html(html)
		jQuery(".-body ._contextmenu").show()
		jQuery(".-body ._contextmenu").css({top:e.pageY,left:e.pageX});
		return false;
	});
	//菜单隐藏
	jQuery("body").bind("click", function(e){
		jQuery(".-body ._contextmenu").hide();
		jQuery(".-main_list ._tr").removeClass('_contextmenu_hover');
	});
});
jQuery(function(){
	jQuery(".checkbox").change(function (){
		if(jQuery("input:checked").val()){
			jQuery("#chkall_del").removeAttr("disabled","disabled");
		}else{
			jQuery("#chkall_del").attr("disabled","disabled");
		}
	});
})
</script>
<form action="" method="get" class="_crmtop">
	<input type="button" value="栏目设置" onclick="Aform.column()"/>
	<input type="button" value="添加" onclick="Aform.add(0,'添加客户','_add')"/>
	地区：<span id="search_area"></span>
	签约：
	<!--{form 'select','sign_status',$sign_status,'',$post[sign_status]}--> 
	所属QQ：
	<!--{form 'select','uqq',$this->model->enum[uqq],'',$post[uqq]}--> 
	<select name="sop">
		<option value="">模糊查询</option>
		<!--{loop $column_sop $key $val}-->
		<option value="$key" <!--{if $key==$post[sop]}-->selected="selected"<!--{/if}-->>$val</option>
		<!--{/loop}-->
	</select>
	<input type="text" name="search" value="$post[search]" size="20"/>
	<input type="submit" value="搜索">
	<!--{if $this->Aact=='my'}-->
	<input type="button" onclick="CRM.find.all()" value="搜索所有">
	<!--{/if}-->
</form>
<div class="_data_column dis_none">
	<div class="_list">$column_html</div>
	<input type="submit" value="确定"/>
</div>
<!--{if $this->Aact=='list'}-->
<!--{Atemplate customer/user}-->
<div class="-main_list _customer_list">
<!--{else}-->
<div class="-main_list _customer_my">
<!--{/if}-->
<form action="" method="POST">
<table class="-table _width">
	<tr class="th">
		<!--{if $this->Aact=='list'}-->
		<th><b>员工</b></th>
		<!--{/if}-->
	<!--{loop $column $key $val}-->
		<th><b><a href="$page->theurl-aorder-$key,$pages->neworder$pages->other">$val</a></b></th>
	<!--{/loop}-->
	</tr>
<!--{loop $list $key $val}-->
<!--{eval
$mid = $val->$key_name;
}-->
	<tr class="_tr" id="$mid">
	<!--{if $this->Aact=='list'}-->
		<td><!--{if !empty($val->username)}-->$val->username<!--{else}-->客户池<!--{/if}--></td>
	<!--{/if}-->
		<!--{eval echo $obj->for_html($key,$val,$column,$this->model,'Aform');}-->
		<input type="hidden" name="save[{$key}][id]" size="1" value="$val->id">
	</tr>
<!--{/loop}-->
</table>
</form>
</div>

<!--{Atemplate customer/nav}-->

<!--{Atemplate tpl/nofooter}-->